﻿namespace _01_单例模式;

public class Singleton
{

    private Guid _guid;

    private static Singleton? _instance;

    private Singleton()
    {
        _guid = Guid.NewGuid();
    }

    public static Singleton CreateInstance()
    {
        if (_instance is null)
        {
            _instance = new Singleton();
        }
        return _instance;
    }

    public void GetId()
    {
        Console.WriteLine(_guid);
    }

    public Guid GetGuid() => _guid;
}